package controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;

@Controller
public class Upload {
    @ResponseBody
    @RequestMapping(value = "/upload",produces = "application/json;charset=UTF-8")
    public String uploadUserHeader(String token, MultipartFile file) throws IOException {
        System.out.println(token);
        System.out.println(file);
        String originFile=file.getOriginalFilename();
        System.out.println(Upload.class.getResource("/").getPath()+"img/"+originFile);
        file.transferTo(new File(Upload.class.getResource("/").getPath()+"img/"+originFile));
        return "";
    }
}
